package com.example.quartz.job;

import com.example.common.SpringApplicationContext;
import com.example.listener.service.MyEventService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;


import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;


public class SystemJob  implements Job {



    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        MyEventService myEventService=SpringApplicationContext.getBean(MyEventService.class);
        String printTime = new SimpleDateFormat("yy-MM-dd HH-mm-ss").format(new Date());
        myEventService.addEvent(printTime+"执行了");
        System.out.println("PrintWordsJob start at:" + printTime + ", prints: Hello Job-" + new Random().nextInt(100));
    }

}
